package com.example.yunnan.controller;

import com.example.yunnan.pojo.news;

import com.example.yunnan.service.goodsServices;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
public class goodsController {
    @Autowired
    goodsServices goodsServices;
    /*customer接口数据*/
    @GetMapping("/api/goods")
    public List<news> list() throws Exception {
        return goodsServices.list();
    }
    /*数据库信息更新时候更新接口数据*/
    @PostMapping("/api/goods")
    public news addOrUpdate(@RequestBody news news) throws Exception {
        goodsServices.addOrUpdate(news);
        return news;
    }




    /* @GetMapping("/api/categories/{cid}/books")
    public List<customer> listByCategory(@PathVariable("cid") int cid) throws Exception {
        if (0 != cid) {
            return customerService.listByCategory(cid);
        } else {
            return list();
        }
    }*/
}

